package conan.GUI;


import conan.ServiceLayer.Controller;

import java.awt.Dimension;

import java.awt.Rectangle;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

public class testFrame extends JFrame {
    private JTextField jTextFieldMedarbejderId = new JTextField();
    private JTextField jTextFieldNavn = new JTextField();
    private JTextField jTextFieldStillingsId = new JTextField();
    private JLabel jLabel1 = new JLabel();
    private JLabel jLabel2 = new JLabel();
    private JLabel jLabel3 = new JLabel();
    private JButton jButton1 = new JButton();

    public testFrame() {
        try {
            jbInit();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        this.getContentPane().setLayout( null );
        this.setSize(new Dimension(681, 464));
        this.setTitle( "Conan HR" );
        jTextFieldMedarbejderId.setBounds(new Rectangle(235, 55, 185, 25));
        jTextFieldMedarbejderId.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    jTextFieldMedarbejderId_actionPerformed(e);
                }
            });
        jTextFieldNavn.setBounds(new Rectangle(235, 95, 185, 25));
        jTextFieldNavn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    jTextFieldNavn_actionPerformed(e);
                }
            });
        jTextFieldStillingsId.setBounds(new Rectangle(235, 135, 185, 25));
        jTextFieldStillingsId.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    jTextFieldStillingsId_actionPerformed(e);
                }
            });
        jLabel1.setText("Medarbejder ID");
        jLabel1.setBounds(new Rectangle(95, 55, 130, 25));
        jLabel1.setHorizontalAlignment(SwingConstants.RIGHT);
        jLabel2.setText("Medarbejder navn");
        jLabel2.setBounds(new Rectangle(110, 95, 115, 25));
        jLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
        jLabel3.setText("Stillings ID");
        jLabel3.setBounds(new Rectangle(100, 135, 125, 25));
        jLabel3.setHorizontalAlignment(SwingConstants.RIGHT);
        jButton1.setText("Gem");
        jButton1.setBounds(new Rectangle(235, 175, 75, 20));
        jButton1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    jButton1_actionPerformed(e);
                }
            });
        this.getContentPane().add(jButton1, null);
        this.getContentPane().add(jLabel3, null);
        this.getContentPane().add(jLabel2, null);
        this.getContentPane().add(jLabel1, null);
        this.getContentPane().add(jTextFieldStillingsId, null);
        this.getContentPane().add(jTextFieldNavn, null);
        this.getContentPane().add(jTextFieldMedarbejderId, null);
    }

    private int medarbejderID;
    private void jTextFieldMedarbejderId_actionPerformed(ActionEvent e) {
        medarbejderID = Integer.parseInt(jTextFieldMedarbejderId.getText());
    }

    private String medarbejderNavn;
    private void jTextFieldNavn_actionPerformed(ActionEvent e) {
        medarbejderNavn = jTextFieldNavn.getText();
    }

    private int medarbejderStillingsId;
    private void jTextFieldStillingsId_actionPerformed(ActionEvent e) {
        medarbejderStillingsId = Integer.parseInt(jTextFieldStillingsId.getText());
    }

    private void jButton1_actionPerformed(ActionEvent e) {
        Controller cont = new Controller();
        cont.gemMedarbejder(medarbejderID, medarbejderNavn, medarbejderStillingsId);
    }
}
